<template>
	<view>
		<view class="wrapper">
			<view class="padding grids">
				<view class="grid" style="border-right: 2px solid #B8B8BF;">
					<view class="title">
						累计收益USDT
					</view>
					<view class="number">
						{{usdt}}
					</view>
				</view>
				<view class="grid">
					<view class="title">
						累计收益EPC
					</view>
					<view class="number">
						{{epc}}
					</view>
				</view>
			</view>

			<view class="list">
				<view class="card" v-for="i in hold" :key="i.id">
					<view class="title">
						{{i.product.product_name}}
					</view>
					<view class="info">
						<view>
							<text class="green">{{i.gain}}</text> 静态
						</view>
						<view>
							<text class="green">{{i.coin_type}}</text>
						</view>
						<button class="cu-btn bg-green round" @click="$u.route('/pages/pledge/profit-detail?id='+i.trade_no)">收益记录</button>
					</view>
					<view class="rate">
						<text>日收益率{{i.product.cft_rate}}%</text>
						<text>质押期限{{i.period}}天</text>
						<text>质押金额{{i.coin_amount}}</text>
					</view>
				</view>
			</view>
			
			<view class="flex justify-center" v-show="!show" @click="show=!show">
				<view class="cu-btn line-grey margin-bottom">查看过期项目</view>
			</view>
			
			<view class="list" v-show="show">
				<view class="card expire" v-for="i in expire" :key="i.id">
					<view class="title">
						{{i.product.product_name}}
					</view>
					<view class="info">
						<view>
							<text class="green">{{i.gain}}</text> 静态
						</view>
						<view>
							<text class="green">{{i.coin_type}}</text>
						</view>
						<button class="cu-btn bg-green round" @click="$u.route('/pages/pledge/profit-detail?id='+i.trade_no)">收益记录</button>
					</view>
					<view class="rate">
						<text>日收益率{{i.product.cft_rate}}%</text>
						<text>质押期限{{i.period}}天</text>
						<text>质押金额{{i.coin_amount}}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 导航 -->
		<view class="cu-bar tabbar shopnav margin-bottom-xl">
			<view class="action text-gray" @click="$u.route({ type: 'redirect', url: 'pages/pledge/index' })">
				<image src="../../static/tabbar/zhiya.png" class="icon"></image>
				<view>首页</view>
			</view>
			<view class="action active">
				<image src="../../static/tabbar/more-active.png" class="icon"></image>
				<view>持有</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				hold: [],
				expire: [],
				usda: '',
				epc: ''
			};
		},
		onShow() {
			this.getList();
		},
		methods: {
			getList() {
				this.$u.get('/cft/hold').then(res => {
					let data = res.data.result
					this.hold = data.hold
					this.usdt = data.usdt
					this.epc = data.epc
				})
				this.$u.get('/cft/hold?type=2').then(res => {
					this.expire = res.data.result.hold
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		padding-bottom: 100rpx;
	}

	.grids {
		display: flex;
		flex-flow: row wrap;
		justify-content: space-around;
		font-size: 36rpx;
		margin: 20rpx 0;

		.grid {
			display: flex;
			flex-flow: column;
			align-items: center;
			width: 50%;
			box-sizing: border-box;
			padding: 20rpx 0;

			.number {
				margin-top: 20rpx;
				font-size: 48rpx;
				font-weight: 400;
				color: #fff;
			}
		}
	}


	.card {
		color: #D6D6D7;
		background: #1B1B3B;
		padding: 20rpx 30rpx;
		border-radius: 20rpx;
		margin-bottom: 30rpx;
		line-height: 2;
		display: flex;
		flex-direction: column;

		.title {
			font-size: 32rpx;
			font-family:Source Han Sans CN;
			letter-spacing: 2rpx;
			color: #fff;
		}

		.info {
			display: flex;
			color: #fff;
			justify-content: space-between;
			align-items: center;
			font-size: 24rpx;
			
			.green {
				font-size: 40rpx;
				color: #00D28B;
				margin-right: 10rpx;
			}
		}
		
		.rate {
			margin-top: 10rpx;
			font-size: 20rpx;
			display: flex;
			justify-content: space-between;
		}

		.cu-btn {
			background: #00D28B;
		}
	}
	
	.expire {
		.title, .info, .rate, .green {
			color: #B8B8BF !important;
		}
		.cu-btn {
			background: #999999;
		}
	}

	.tabbar {
		background-color: #434657;
		position: fixed;
		width: 100%;
		z-index: 999;
		bottom: 0;
		margin: 0;

		.icon {
			margin: 8rpx;
			width: 40rpx;
			height: 40rpx;
		}
	}
</style>
